layui.config({
  base: "js/"
}).use(['form', 'layer', 'jquery', 'layedit', 'laydate'], function () {
  var form = layui.form(),
    layer = parent.layer === undefined ? layui.layer : parent.layer,
    laypage = layui.laypage,
    layedit = layui.layedit,
    laydate = layui.laydate,
    $ = layui.jquery;

  var score = JSON.parse(sessionStorage.getItem("score"))[0];

  console.log("score", score);

  $('#Cos_id').val(score.Cos_id);
  $('#Stu_id').val(score.Stu_id);
  $('#Score').val(score.Score);

  form.on("submit(submit)", function (data) {
    //弹出loading
    var index = layer.msg('数据提交中，请稍候', {icon: 16, time: 3000, shade: 0.8});
    $.ajax({
      url: "/api/score/" + data.field.Cos_id + "/" + data.field.Stu_id,
      type: "PUT",
      data: data.field,
      dataType: "json",
      success: function (data) {
        console.log(data);
        layer.close(index);
        top.layer.msg("修改成功！");
        layer.closeAll("iframe");
      },
      error: function (data) {
        layer.close(index);
        top.layer.msg("修改失败！");
      }
    });
    return false;
  })

});
